package com.water.quality.testing.dao;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.sql.Timestamp;


/**
 * 水质实体层
 */
@TableName("water_data") // 映射数据库表 water_data
public class WaterData {

    /**
     * id
     */
    private String id;

    /**
     * 观测点ID
     */
    private Long observationPointId;

    /**
     * 观测点名字
     */
    private String observationPointName;

    /**
     * 透明度
     */
    private double clarity;
    /**
     * 透明度变化值
     */
    private double clarityChange;

    /**
     * pH值
     */
    @TableField("ph")
    private double pH;

    /**
     * pH值变化值
     */
    @TableField("pH_change")
    private double pHChange;

    /**
     * 颗粒大小
     */
    private double particleSize;

    /**
     * 颗粒大小变化值
     */
    private double particleSizeChange;

    /**
     * 电导率
     */
    private double conductivity;

    /**
     * 电导率变化值
     */
    private double conductivityChange;

    /**
     * 温度
     */
    private double temperature;

    /**
     * 温度变化值
     */
    private double temperatureChange;


    /**
     * 水质等级
     */
    private String qualityLevel;

    /**
     *  数据创建时间
     */
    private Timestamp createdAt;

    // 无参构造函数
    public WaterData() {}

    // 全参构造函数
    public WaterData(double clarity, double pH, double particleSize, double conductivity, double temperature, Long observationPointId, String observationPointName) {
        this.clarity = clarity;
        this.pH = pH;
        this.particleSize = particleSize;
        this.conductivity = conductivity;
        this.temperature = temperature;
        this.observationPointId = observationPointId;
        this.observationPointName = observationPointName;
        this.qualityLevel = assessQualityLevel();
    }

    /**
     * 评估水质等级
     */
    private String assessQualityLevel() {
        if (clarity > 7 && pH >= 6.5 && pH <= 8.5 && particleSize < 150 && conductivity < 1500) {
            return "正常";
        } else if (clarity > 5 && pH >= 6 && pH <= 9 && particleSize < 200 && conductivity < 2000) {
            return "较好";
        } else if (clarity > 3 && pH >= 5.5 && pH <= 9.5 && particleSize < 300 && conductivity < 3000) {
            return "严重污染";
        } else {
            return "较好";
        }
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getQualityLevel() {
        return qualityLevel;
    }

    public void setQualityLevel(String qualityLevel) {
        this.qualityLevel = qualityLevel;
    }


    public Long getObservationPointId() {
        return observationPointId;
    }

    public void setObservationPointId(Long observationPointId) {
        this.observationPointId = observationPointId;
    }

    public double getClarity() {
        return clarity;
    }

    public void setClarity(double clarity) {
        this.clarity = clarity;
    }

    public double getClarityChange() {
        return clarityChange;
    }

    public void setClarityChange(double clarityChange) {
        this.clarityChange = clarityChange;
    }

    public double getPH() {
        return pH;
    }

    public void setPH(double pH) {
        this.pH = pH;
    }

    public double getPHChange() {
        return pHChange;
    }

    public void setPHChange(double pHChange) {
        this.pHChange = pHChange;
    }

    public double getParticleSize() {
        return particleSize;
    }

    public void setParticleSize(double particleSize) {
        this.particleSize = particleSize;
    }

    public double getParticleSizeChange() {
        return particleSizeChange;
    }

    public void setParticleSizeChange(double particleSizeChange) {
        this.particleSizeChange = particleSizeChange;
    }

    public double getConductivity() {
        return conductivity;
    }

    public void setConductivity(double conductivity) {
        this.conductivity = conductivity;
    }

    public double getConductivityChange() {
        return conductivityChange;
    }

    public void setConductivityChange(double conductivityChange) {
        this.conductivityChange = conductivityChange;
    }

    public double getTemperature() {
        return temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }

    public double getTemperatureChange() {
        return temperatureChange;
    }

    public void setTemperatureChange(double temperatureChange) {
        this.temperatureChange = temperatureChange;
    }

    public Timestamp getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.createdAt = createdAt;
    }

    public String getObservationPointName() {
        return observationPointName;
    }

    public void setObservationPointName(String observationPointName) {
        this.observationPointName = observationPointName;
    }
}
